package svn.project;

import java.io.FileOutputStream;
import java.util.prefs.Preferences;

public class PresNode {
	
	public PresNode(String projectName) {
		this.projectName = projectName;
		node = Preferences.userRoot().node("/org/svn/init");
		System.out.println(node + projectName);
	}
	
	public String getUrls() {
		return node.get(projectName, DEFAULT_URL);
	}
	
	public void setUrls(String Urls) {
		if(getUrls().equals(DEFAULT_URL))
			node.put(projectName, Urls + "|");
		else
			node.put(projectName, getUrls() + Urls + "|");
	}
	
	public void getXmlFile() {
		try {
			FileOutputStream fos = new FileOutputStream("prefsnode.xml");
			node.exportNode(fos);
		} 
		catch (Exception e) {
			System.err.println("Cannot export nodes: " + e);
		}
	}
	
	
	public static void main(String[] args) {
		PresNode p = new PresNode("svn");
		p.setUrls("http://localhost:8081/svn/repos/default");
	}
	private String projectName;
	private static final String DEFAULT_URL = "url";
	private Preferences node;
}
